<template>
 <u-tabbar
     :list="tabList" 
         v-model="activeIndex" 
         @change="onTabChange"
  >
  </u-tabbar>
</template>
<script>
export default {
  props: {
    value: {
      type: Number,
      default: 0,
    },
  },
  data() {
    return {
		 activeIndex: 0,
		      tabList: [
		        {
		          icon: 'home',
		          text: '首页',
		          pagePath: 'pages/index/index'
		        },
		        {
		          icon: 'search',
		          text: '搜索',
		          pagePath: 'pages/worker/index'
		        },
		        {
		          icon: 'user',
		          text: '我的',
		          pagePath: 'pages/user/index'
		        }
		      ]
	};
  },
  methods: {
	      onTabChange(index) {
	        this.activeIndex = index;
	        // 跳转到相应页面
	        uni.switchTab({
	          url: this.tabList[index].pagePath
	        });
	      }
	    },
    change(e) {
      switch (e) {
        case 0:
          uni.switchTab({ url: "/pages/index/index" });
          break;
        case 1:
          uni.switchTab({ url: "/pages/worker/index" });
          break;
        case 2:
          uni.switchTab({ url: "/pages/message/index" });
          break;
        case 3:
		    // if(uni.getStorageSync('token')){
				uni.switchTab({ url: "/pages/user/index" });
			// }else{
			// 	uni.navigateTo({ url: "/pagesC/login/login" });
			// }
          break;
      }
    },
  },
};
</script>
<style>
	.container {
	  display: flex;
	  flex-direction: column;
	  height: 100%;
	}
	.content {
	  flex: 1;
	  display: flex;
	  align-items: center;
	  justify-content: center;
	}
	.u-page__item__slot-icon{ width: 40rpx; height: 40rpx;}
	.u-tabbar--fixed.data-v-542a922e {
		z-index: 9999;
	}
</style>